package com.homer.android.sdk.db.greenrobot.daos;



import com.homer.android.sdk.object.db.IGenericDataDB;
import com.homer.android.sdk.util.TimeUtil;

import de.greenrobot.dao.DaoException;

public class GenericDataDB implements IGenericDataDB
{
    
    private Long id;
    
    private long deviceId;
    
    private long timestamp;
    
    /** Not-null value. */
    private String data;
    
    private long directoryId;
    
    /** Used to resolve relations */
    private transient DaoSession daoSession;
    
    /** Used for active entity operations. */
    private transient GenericDataDBDao myDao;
    
    private GenericDataDirectoryDB genericDataDirectoryDB;
    
    private Long genericDataDirectoryDB__resolvedKey;
    
    // KEEP FIELDS - put your custom fields here
    // KEEP FIELDS END
    
    public GenericDataDB()
    {
    }
    
    public GenericDataDB(Long id)
    {
        this.id = id;
    }
    
    public GenericDataDB(Long id, long deviceId, long timestamp, String data, long directoryId)
    {
        this.id = id;
        this.deviceId = deviceId;
        this.timestamp = timestamp;
        this.data = data;
        this.directoryId = directoryId;
    }
    
    /** called by internal mechanisms, do not call yourself. */
    public void __setDaoSession(DaoSession daoSession)
    {
        this.daoSession = daoSession;
        myDao = daoSession != null ? daoSession.getGenericDataDBDao() : null;
    }
    
    public Long getId()
    {
        return id;
    }
    
    public void setId(Long id)
    {
        this.id = id;
    }
    
    public long getDeviceId()
    {
        return deviceId;
    }
    
    public void setDeviceId(long deviceId)
    {
        this.deviceId = deviceId;
    }
    
    public long getTimestamp()
    {
        return timestamp;
    }
    
    public void setTimestamp(long timestamp)
    {
        this.timestamp = timestamp;
    }
    
    /** Not-null value. */
    public String getData()
    {
        return data;
    }
    
    /** Not-null value; ensure this value is available before it is saved to the database. */
    public void setData(String data)
    {
        this.data = data;
    }
    
    public long getDirectoryId()
    {
        return directoryId;
    }
    
    public void setDirectoryId(long directoryId)
    {
        this.directoryId = directoryId;
    }
    
    /** To-one relationship, resolved on first access. */
    public GenericDataDirectoryDB getGenericDataDirectoryDB()
    {
        long __key = this.directoryId;
        if (genericDataDirectoryDB__resolvedKey == null || !genericDataDirectoryDB__resolvedKey.equals(__key))
        {
            if (daoSession == null)
            {
                throw new DaoException("Entity is detached from DAO context");
            }
            GenericDataDirectoryDBDao targetDao = daoSession.getGenericDataDirectoryDBDao();
            GenericDataDirectoryDB genericDataDirectoryDBNew = targetDao.load(__key);
            synchronized (this)
            {
                genericDataDirectoryDB = genericDataDirectoryDBNew;
                genericDataDirectoryDB__resolvedKey = __key;
            }
        }
        return genericDataDirectoryDB;
    }
    
    public void setGenericDataDirectoryDB(GenericDataDirectoryDB genericDataDirectoryDB)
    {
        if (genericDataDirectoryDB == null)
        {
            throw new DaoException("To-one property 'directoryId' has not-null constraint; cannot set to-one to null");
        }
        synchronized (this)
        {
            this.genericDataDirectoryDB = genericDataDirectoryDB;
            directoryId = genericDataDirectoryDB.getId();
            genericDataDirectoryDB__resolvedKey = directoryId;
        }
    }
    
    /** Convenient call for {@link AbstractDao#delete(Object)}. Entity must attached to an entity context. */
    public void delete()
    {
        if (myDao == null)
        {
            throw new DaoException("Entity is detached from DAO context");
        }
        myDao.delete(this);
    }
    
    /** Convenient call for {@link AbstractDao#update(Object)}. Entity must attached to an entity context. */
    public void update()
    {
        if (myDao == null)
        {
            throw new DaoException("Entity is detached from DAO context");
        }
        myDao.update(this);
    }
    
    /** Convenient call for {@link AbstractDao#refresh(Object)}. Entity must attached to an entity context. */
    public void refresh()
    {
        if (myDao == null)
        {
            throw new DaoException("Entity is detached from DAO context");
        }
        myDao.refresh(this);
    }
    
    // KEEP METHODS - put your custom methods here
    @Override
    public String toString()
    {
        return "GenericDataDB: (id=[" + id + "],deviceId=[" + deviceId + "],timestamp=["
            + TimeUtil.getDateStr(timestamp, null) + "],data=[" + data + "],directoryId=[" + directoryId + "])";
    }
    // KEEP METHODS END
    
}

